package com.brillilab.service.core.system.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.brillilab.dao.mapper.system.LogManageMapper;
import com.brillilab.domain.po.system.LogManage;
import com.brillilab.service.core.system.ILogManageService;

@Service
public class LogManageServiceImpl implements ILogManageService {

	@Resource
	private LogManageMapper logManageMapper;

	@Override
	public void addLoginLog(LogManage logManage) {
		LambdaQueryWrapper<LogManage> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(LogManage::getUserId, logManage.getUserId());
		wrapper.eq(LogManage::getLogType, logManage.getLogType());
		LogManage manage = logManageMapper.selectOne(wrapper);
		if(manage!=null) {
			logManage.setId(manage.getId());
			logManageMapper.updateById(logManage);
		}else {
			logManageMapper.insert(logManage);
		}
	}
	
	@Override
	public void addRegisterLog(LogManage logManage) {
		logManageMapper.insert(logManage);
	}

}
